package com.atguigu.day05;

import com.atguigu.day03.Example8;
import org.apache.flink.runtime.state.StateBackend;
import org.apache.flink.runtime.state.StateBackendLoader;
import org.apache.flink.runtime.state.filesystem.FsStateBackend;
import org.apache.flink.streaming.api.CheckpointingMode;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.operators.sorted.state.BatchExecutionStateBackend;

/**
 * 检查点
 */
public class Example2 {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        env.enableCheckpointing(10 * 1000L, CheckpointingMode.EXACTLY_ONCE);
        env.setStateBackend(new BatchExecutionStateBackend());
        env.setStateBackend(new FsStateBackend("file:\\D:\\WebSite\\flink\\flink\\java_flink\\src\\main\\resources\\ckpt", false));
        env.
                readTextFile("D:\\WebSite\\flink\\flink\\java_flink\\src\\main\\resources\\UserBehavior.csv")
                .print();

        env.execute();
    }
}
